package com.example.mapper;

import com.example.pojo.entity.Admin;
import com.example.pojo.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Insert("insert into  `user` (username,password,name,sex,avatar,role,phone,email,address) values" +
            " (#{username},#{password},#{name},#{sex},#{avatar},#{role},#{phone},#{email},#{address})")
    void insert(User user);

    @Update("update `user` set username = #{username},password = #{password},name = #{name},sex = #{sex}," +
            "avatar = #{avatar},role = #{role},phone = #{phone},email = #{email},address = #{address} where id = #{id}")
    void update(User user);

    @Delete("delete from `user` where id = #{id}")
    void delete(Integer id);


    @Delete("delete from `user` where id = #{id}")
    void batchdelete(Integer id);

    @Select("select * from `user` order by id DESC ")
    List<User> selectAll();

    @Select("select * from `user` where id = #{id}")
    User selectById(Integer id);

    @Select("select * from `user` where name = #{name} order by id DESC ")
    List<User> selectByName(String name);

    @Select("select * from `user` where name = #{name} and username = #{username} order by id DESC ")
    List<User> selectMore(@Param("name") String name,@Param("username") String username);

    @Select("select * from `user` where name like concat('%',#{name},'%')  or " +
            "username like concat('%',#{username},'%')  order by id DESC ")
    List<User> selectLike(String name, String username);

    @Select("select * from `user` where username = #{username} order by id DESC ")
    User selectByUsername(String username);

    List<User> selectByPage(String name, String username);

    @Select("select * from `user` where name = #{name}  ")
    User selectByName1(String name);

    @Select("select * from `user` where phone = #{phone}  ")
    User selectByPhone(String phone);


   
}
